package pl.kosmowska.ewelina.server.jdo;

import java.util.Date;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Version;
import javax.jdo.annotations.VersionStrategy;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@PersistenceCapable
@Version(strategy=VersionStrategy.VERSION_NUMBER, column="version", extensions={@Extension(vendorName="datanucleus", key="key", value="version")})
public class StockData implements DatabaseEntity<String>{

	/**
	 * primary id
	 * transposed to web safe id (base64) for transport
	 */
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;

	/**
	 * mandatory parameter used with request factory
	 * @Version in JPA annotation
	 */
	@Persistent
	private Long version;

	/**
	 * entity owner - the person who's logged in
	 */
	@Persistent
	private Long userId; 

	/**
	 * name of the Stock
	 */

	// TODO: do zmiany
	@Persistent
	private String name;

	@Persistent
	private float percentage;

	@Persistent
	private Date startDate;
	
	@Persistent
	private float startValue;
	
	@Persistent
	private float currentValue;
	
	@Persistent
	private int stockNumber;
	
	@Persistent
	private float totalValue;

	
	public int getStockNumber() {
		return stockNumber;
	}

	public void setStockNumber(int stockNumber) {
		this.stockNumber = stockNumber;
	}

	public float getTotalValue() {
		return totalValue;
	}

	public void setTotalValue(float totalValue) {
		this.totalValue = totalValue;
	}

	public float getStartValue() {
		return startValue;
	}

	public void setStartValue(float startValue) {
		this.startValue = startValue;
	}

	public float getCurrentValue() {
		return currentValue;
	}

	public void setCurrentValue(float currentValue) {
		this.currentValue = currentValue;
	}

	public float getPercentage() {
		return percentage;
	}

	public void setPercentage(float percentage) {
		this.percentage = percentage;
	}


	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}


	public void setId(String id) {
		if (id == null) {
			return;
		}
		key = KeyFactory.stringToKey(id);
	}
	public String getId() {
		String id = null;
		if (key != null) {
			id = KeyFactory.keyToString(key);
		}
		return id;
	}

	public void setVersion(Long version) {
		this.version = version;
	}
	public Long getVersion() {
		if (version == null) {
			version = 0l;
		}
		return version;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}
	public Long getUserId() {
		return userId;
	}

	public void setName(String name) {
		this.name = name;
	}
	public String getName() {
		return name;
	}





}
